//
//  drawerViewController.m
//  myMusicApp
//
//  Created by 11_wyq on 15/6/17.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "drawerViewController.h"

@interface drawerViewController ()

@end

@implementation drawerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor clearColor];


    
    
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 190 * HEIGHT, MYWIDTH, 447  * HEIGHT)];
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.tableView];
    [_tableView release];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//取消cell之间的线

    
    
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellName = @"myCell";
    drawerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
    if (cell == nil) {
        
        cell = [[drawerTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName andNumber:indexPath.row];
      
        
    }
    
    
    cell.backgroundColor = [UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;//取消点击效果
    
    return cell;
}



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (indexPath.row == 0) {
      MainTabBarController *bar = [[MainTabBarController alloc]init];
        [self.sideMenuViewController setContentViewController:bar animated:YES];
        [self.sideMenuViewController hideMenuViewController];//返回主界面
        
        [bar release];
    }
    if(indexPath.row == 1){
    
        ChannelVC *channelVC = [[ChannelVC alloc]init];
        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:channelVC] animated:YES];//改变主界面页面
        [self.sideMenuViewController hideMenuViewController];//返回主界面
        
        [channelVC release];
        
        
        
    }
    if(indexPath.row == 2){
        ListOfVViewController *ListOfVVC = [[ListOfVViewController alloc]init];
        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:ListOfVVC] animated:YES];//改变主界面页面
        [self.sideMenuViewController hideMenuViewController];//返回主界面
        

        [ListOfVVC release];
        
    }
    if(indexPath.row == 3){
        myCollectionVC *collect = [[myCollectionVC alloc]init];
        [[DataHandle shareHandleController]openDB];
        NSMutableArray *FMarray = [[DataHandle shareHandleController]selectMusicFMCollection];
        NSMutableArray *MVarray = [[DataHandle shareHandleController]selectCollect];
        

        
        if (FMarray.count == 0 && MVarray.count == 0) {
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"收藏点东西再来吧~" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
            [alertView show];
            return;
        }
        
        
        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:collect] animated:YES];//改变主界面页面
        [self.sideMenuViewController hideMenuViewController];//返回主界面
        
        
        [collect release];
        
    }
    if(indexPath.row == 4){
        InstallViewController *install = [[InstallViewController alloc] init];
        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:install] animated:YES];//改变主界面页面
        [self.sideMenuViewController hideMenuViewController];//返回主界面
        
        
        [install release];
        
          }
    
    
    
    
    
}


- (void)sideMenu:(RESideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController
{
    NSLog(@"willHideMenuViewController: %@", NSStringFromClass([menuViewController class]));
}

- (void)sideMenu:(RESideMenu *)sideMenu didHideMenuViewController:(UIViewController *)menuViewController
{
    NSLog(@"didHideMenuViewController: %@", NSStringFromClass([menuViewController class]));
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
